package com.huluobo.a2109kotlinshopping.cart

import android.widget.CheckBox
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.huluobo.a2109kotlinshopping.R
import com.huluobo.a2109kotlinshopping.utils.ImageUtils

/**
 *  Created by LC on 2024/1/15.
 */
class CartAdapter(list: MutableList<CartBean>) : BaseQuickAdapter<CartBean, BaseViewHolder>(R.layout.item_cart, list) {
    override fun convert(helper: BaseViewHolder, item: CartBean) {
        //商品图片
        ImageUtils.loadImage(context, item.goods_default_icon, helper.getView(R.id.cart_item_iv_icon))

        //商品名称
        helper.setText(R.id.cartItem_tv_name, item.goods_desc)

        //商品价格
        helper.setText(R.id.cart_item_tv_price, "价格:￥${item.goods_default_price}元")

        //商品数量
        helper.setText(R.id.cart_item_tv_num, item.count.toString())

        //选中按钮
        helper.getView<CheckBox>(R.id.cart_item_cb).isChecked = item.isChecked
    }
}